#include "aatracker.h"


//long long int converterParaLongInt (char* str){
double convertToDouble (char* str){

    //unsigned long long int res =0;
    double res =0;

    int i=0;
    int decValue =0;
    for (i = 0; ; i++) {

        //48 eh o valor decimal do 1o numero na tabela ascii, o zero
        decValue = ((int)str[i] )-48;
        if (( decValue >= 0) &&( decValue <= 9)) {
            res*=10; res+=decValue;
        }
        else { if (i==0) { return INVALID_NUMBER;} else return res;}
    }
    return res;
}

int convertToInt (char* str){


    //unsigned long long int res =0;
    int res =0;

    int i=0;
    int decValue =0;
    for (i = 0; ; i++) {

        //48 eh o valor decimal do 1o numero na tabela ascii, o zero
        decValue = ((int)str[i] )-48;
        if (( decValue >= 0) &&( decValue <= 9)) {
            res*=10; res+=decValue;
        }
        else { if (i==0) { return INVALID_NUMBER;} else return res;}
    }
    return res;
}

int strnlen2 (const char *str, int maxlen){

    const char *s = str, *max = str+maxlen;

    for (; (s!='\0' && s<max); s++){
    }

    return s-str;
}

